package fit.conceptmap.entities;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the member_assignment database table.
 * 
 */
@Entity
@Table(name="member_assignment")
@NamedQuery(name="MemberAssignment.findAll", query="SELECT m FROM MemberAssignment m")
public class MemberAssignment implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private String idmember_Assignment;

	private int code;

	@Temporal(TemporalType.TIMESTAMP)
	private Date endDate;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="idUser")
	private User user;

	//bi-directional many-to-one association to Assignment
	@ManyToOne
	@JoinColumn(name="idAssignment")
	private Assignment assignment;

	//bi-directional many-to-one association to Relationship
	@OneToMany(mappedBy="memberAssignment")
	private List<Relationship> relationships;

	public MemberAssignment() {
	}

	public String getIdmember_Assignment() {
		return this.idmember_Assignment;
	}

	public void setIdmember_Assignment(String idmember_Assignment) {
		this.idmember_Assignment = idmember_Assignment;
	}

	public int getCode() {
		return this.code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public Date getEndDate() {
		return this.endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Assignment getAssignment() {
		return this.assignment;
	}

	public void setAssignment(Assignment assignment) {
		this.assignment = assignment;
	}

	public List<Relationship> getRelationships() {
		return this.relationships;
	}

	public void setRelationships(List<Relationship> relationships) {
		this.relationships = relationships;
	}

	public Relationship addRelationship(Relationship relationship) {
		getRelationships().add(relationship);
		relationship.setMemberAssignment(this);

		return relationship;
	}

	public Relationship removeRelationship(Relationship relationship) {
		getRelationships().remove(relationship);
		relationship.setMemberAssignment(null);

		return relationship;
	}

}